package com.example.t1.activity;

import java.io.IOException;
import java.io.InputStream;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;

import com.example.t1.R;

public class Activity1 extends Activity implements OnClickListener {

    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_acctivity1);
	Button button = (Button) findViewById(R.id.button1);
	button.setOnClickListener(this);
	RatingBar bar = (RatingBar) findViewById(R.id.ratingBar1);
	bar.setRating(2f);
	bar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

	    @Override
	    public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) {
		Log.d("tag",Math.round(arg0.getRating()) + "");
	    }
	});
	
	ImageView imageView = (ImageView) findViewById(R.id.imageView1);
	try {
	    InputStream stream = getResources().getAssets().open(
		    "beautiful.jpeg");
//	    getResources().get
	    BitmapDrawable drawable = new BitmapDrawable(
		    BitmapFactory.decodeStream(stream));
	    int width = drawable.getIntrinsicWidth();
	    int height = drawable.getIntrinsicHeight();
//	    imageView.setBackground(drawable);
	} catch (IOException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
    }

  

    @Override
    public void onClick(View arg0) {

	switch (arg0.getId()) {
	case R.id.button1:
	    setResult(RESULT_OK);
	    // setResult(, );
	    break;

	default:
	    break;
	}
    }

}
